////////////////////////////////////////////////
// File: MeminfoService.java
// Description: Enter summary here after generation.
// Date: 2016-09-23 09:09:33
// Web: http://www.elanzhou.com/
////////////////////////////////////////////////
package com.mvc.service;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.mvc.dao.EntityDao;
import com.mvc.entity.Meminfo;
import com.pub.Page;

@Service
public class  MeminfoService {
	@Autowired
	private EntityDao entityDao;

	@Transactional
	public List<Object> getMeminfoList(String hql, Page page) {
		List<Object> list = entityDao.pageQuery(hql, page.getPageNo(),
				page.getPageSize());
		return list;
	}

	public int getCount(String hql, Page page) {
		int count = 0;
		count = entityDao.countQuery(hql);
		if ((count % page.getPageSize()) == 0) {
			count = count / page.getPageSize();
		}else
		{
			count = count / page.getPageSize() + 1;
		}
		return count;
	}

	public void Save( Meminfo  meminfo) {
		entityDao.save(meminfo);
	}

	public void EditSave(Meminfo meminfo) {
		entityDao.saveOrUpdate(meminfo);
	}

	public void Del(String ID) {
		entityDao.delById(Meminfo.class, Integer.parseInt(ID));
	}

	public Meminfo getMeminfoByHql(String hql) {
		Meminfo meminfo = (Meminfo) entityDao.loadObject(hql);
		return meminfo;
	}
	public Meminfo getMeminfoByName(String Memname) {
		String hql="select a from Meminfo a where a.Memname='"+Memname+"'";
		Meminfo meminfo = (Meminfo) entityDao.loadObject(hql);
		return meminfo;
	}  
   public Meminfo getMeminfo(String ID){
	   Meminfo meminfo=(Meminfo) entityDao.loadById(Meminfo.class,Integer.valueOf(ID));
	   return meminfo;
      }
	public List<Object> getListByHql(String hql) {
		List<Object> list = entityDao.query(hql);
		return list;
	}
	public List<Object> getBank() {
		String hql="select distinct a.Companyname from Meminfo a where a.Rolename='银行'";
		List<Object> list = entityDao.query(hql);
		return list;
	}
}
